<?php


namespace app\merchant\controller;


use app\common\controller\Common;
use WxJDK\JSSDK;

class Scanqrcode extends Common
{

    public function index()
    {
        # 公众号获取
        $appid = config('app.appid');
        # 公众号获取
        $appSecret = config('app.appsecret');
        # 实例化
        $url=request()->param('url');
        $wx = new JSSDK($appid, $appSecret,$url);
        # 获取参数
        $info = $wx->getWxConfig();
        //$info['url'] = str_replace('http://', '', $info['url']);
        # 传参页面
        return $this->okJson('ok',$info);
    }

    public function WeChat()
    {
        return ['appId' => config('WeChat')['appId'], 'timestamp' => time(), 'noncestr' => '123456', 'signature' => ''];
    }

    public function sp()
    {
        # 公众号获取
        $appid = config('wechat')['wechat_options']['appid'];
        # 公众号获取
        $appSecret = config('wechat')['wechat_options']['appsecret'];
        $wx = new JSSDK($appid, $appSecret);
        $wx->getCommodityInfo(input('ISBN'));
        return $this->fetch('index');
    }

}